home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ALPH.{_4 / HARDIRQ.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  76 lines

  1. #ifndef _ALPHA_HARDIRQ_H
  2. #define _ALPHA_HARDIRQ_H
  3.  
  4. /* Initially just a straight copy of the i386 code.  */
  5.  
  6. #include <linux/tasks.h>
  7.  
  8. extern unsigned int local_irq_count[NR_CPUS];
  9. extern unsigned long hardirq_no[NR_CPUS];
  10.  
  11. /*
  12.  * Are we in an interrupt context? Either doing bottom half
  13.  * or hardware interrupt processing?
  14.  */
  15.  
  16. #define in_interrupt()                        \
  17. ({                                \
  18.     int __cpu = smp_processor_id();                \
  19.     (local_irq_count[__cpu] + local_bh_count[__cpu]) != 0;    \
  20. })
  21.  
  22. #ifndef __SMP__
  23.  
  24. #define hardirq_trylock(cpu)    (local_irq_count[cpu] == 0)
  25. #define hardirq_endlock(cpu)    ((void) 0)
  26.  
  27. #define hardirq_enter(cpu, irq)    (local_irq_count[cpu]++)
  28. #define hardirq_exit(cpu, irq)    (local_irq_count[cpu]--)
  29.  
  30. #define synchronize_irq()    barrier()
  31.  
  32. #else
  33.  
  34. #include <asm/atomic.h>
  35. #include <asm/spinlock.h>
  36. #include <asm/smp.h>
  37.  
  38. extern int global_irq_holder;
  39. extern spinlock_t global_irq_lock;
  40. extern atomic_t global_irq_count;
  41.  
  42. static inline void release_irqlock(int cpu)
  43. {
  44.     /* if we didn't own the irq lock, just ignore.. */
  45.     if (global_irq_holder == cpu) {
  46.         global_irq_holder = NO_PROC_ID;
  47.         spin_unlock(&global_irq_lock);
  48.         }
  49. }
  50.  
  51. static inline void hardirq_enter(int cpu, int irq)
  52. {
  53.     ++local_irq_count[cpu];
  54.         atomic_inc(&global_irq_count);
  55.     hardirq_no[cpu] |= 1L << irq;        /* debugging only */
  56. }
  57.  
  58. static inline void hardirq_exit(int cpu, int irq)
  59. {
  60.     hardirq_no[cpu] &= ~(1L << irq);    /* debugging only */
  61.     atomic_dec(&global_irq_count);
  62.         --local_irq_count[cpu];
  63. }
  64.  
  65. static inline int hardirq_trylock(int cpu)
  66. {
  67.     return !atomic_read(&global_irq_count) && !global_irq_lock.lock;
  68. }
  69.  
  70. #define hardirq_endlock(cpu)  ((void)0)
  71.  
  72. extern void synchronize_irq(void);
  73.  
  74. #endif /* __SMP__ */
  75. #endif /* _ALPHA_HARDIRQ_H */
  76.